package com.bing.img.controller;

import com.bing.img.model.Img;
import com.bing.img.service.IImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by Zhou Bing
 * <p>
 * 2017/11/15.
 */
@Controller
@RequestMapping("/img")
public class ImgController {


    @Autowired
    IImgService imgService;

    @RequestMapping(value = "/getImg", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String getImg(String id){
        return imgService.findImgById(id);
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String saveImg(String base64){


        Img img  = imgService.saveImg(base64);

        return img.getId();
    }

}
